﻿using System;
using Newtonsoft.Json;

namespace OneWorks.Web.Common.BaiDu.Place
{
    public enum CaterSortName
    {
        /// <summary>
        /// 默认
        /// </summary>
        Default,
        /// <summary>
        /// 价格
        /// </summary>
        Price,
        /// <summary>
        /// 口味
        /// </summary>
        TasteRating,
        /// <summary>
        /// 好评
        /// </summary>
        OverallRating,
        /// <summary>
        /// 服务
        /// </summary>
        ServiceRating,
        /// <summary>
        /// 距离排序，只有周边检索有效
        /// </summary>
        Distance
    }

    public enum LifeSortName
    {
        /// <summary>
        /// 默认
        /// </summary>
        Default,
        /// <summary>
        /// 价格
        /// </summary>
        Price,

        /// <summary>
        /// 好评
        /// </summary>
        OverallRating,
        /// <summary>
        /// 服务
        /// </summary>
        CommentNum,
        /// <summary>
        /// 距离排序，只有周边检索有效
        /// </summary>
        Distance
    }

    public class BaiduPlaceParams
    {
        /// <summary>
        /// 用户的访问密钥，必填项。v2之前该属性为key。
        /// </summary>
        public string Ak;
        /// <summary>
        /// 用户的权限签名。
        /// </summary>
        public string Sn;
        /// <summary>
        /// 设置sn后该值必填。s
        /// </summary>
        public string Timestamp;

        public override string ToString()
        {
            if (string.IsNullOrWhiteSpace(Ak))
                throw new ArgumentException(BaiduErrorMessages.NotKey);

            string s = "output=json";

            s += "&ak=" + Ak;

            if (!string.IsNullOrWhiteSpace(Sn) && !string.IsNullOrWhiteSpace(Timestamp))
            {
                s += "&sn=" + Sn;
                s += "&timestamp=" + Timestamp;
            }

            return s;
        }
    }

     

   

 
    public class BaiduPlaceResults
    {
        /// <summary>
        /// 本次API访问状态，如果成功返回0，如果失败返回其他数字。
        /// </summary>
        [JsonProperty(PropertyName = "status")]
        public Status Status;
        /// <summary>
        /// 	对API访问状态值的英文说明，如果成功返回"ok"，并返回结果字段，如果失败返回错误说明。
        /// </summary>
        [JsonProperty(PropertyName = "message")]
        public string Message;
        /// <summary>
        /// 检索总数，用户请求中设置了page_num字段才会出现total字段。
        /// </summary>
        [JsonProperty(PropertyName = "total")]
        public int Total;

        [JsonProperty(PropertyName = "results")]
        public BaiduPlaceResult[] Results;

        [JsonProperty(PropertyName = "result")]
        public BaiduPlaceResult Result;
    }

    public class BaiduPlaceResult
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty(PropertyName = "name")]
        public string Name;
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty(PropertyName = "location")]
        public BaiduPlaceLocation Location;
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty(PropertyName = "address")]
        public string Address;
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty(PropertyName = "uid")]
        public string Uid;
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty(PropertyName = "detail_info")]
        public BaiduPlaceDetail DetailInfo;

    }

    public class BaiduPlaceDetail
    {
        /// <summary>
        /// 距离中心点的距离
        /// </summary>
        [JsonProperty(PropertyName = "distance")]
        public string Distance;
        /// <summary>
        /// 	所属分类，如’hotel’、’cater’。
        /// </summary>
        [JsonProperty(PropertyName = "type")]
        public string Type;
        /// <summary>
        /// 标签
        /// </summary>
        [JsonProperty(PropertyName = "tag")]
        public string Tag;
        /// <summary>
        /// poi的详情页
        /// </summary>
        [JsonProperty(PropertyName = "detail_url")]
        public string DetailUrl;
        /// <summary>
        /// poi商户的价格
        /// </summary>
        [JsonProperty(PropertyName = "price")]
        public string Price;
        /// <summary>
        /// 营业时间
        /// </summary>
        [JsonProperty(PropertyName = "shop_hours")]
        public string ShopHours;
        /// <summary>
        /// 总体评分
        /// </summary>
        [JsonProperty(PropertyName = "overall_rating")]
        public string OverallRating;
        /// <summary>
        /// 口味评分
        /// </summary>
        [JsonProperty(PropertyName = "taste_rating")]
        public string TasteRating;
        /// <summary>
        /// 服务评分
        /// </summary>
        [JsonProperty(PropertyName = "service_rating")]
        public string ServiceRating;
        /// <summary>
        /// 环境评分
        /// </summary>
        [JsonProperty(PropertyName = "environment_rating")]
        public string EnvironmentRating;
        /// <summary>
        /// 星级（设备）评分
        /// </summary>
        [JsonProperty(PropertyName = "facility_rating")]
        public string FacilityRating;
        /// <summary>
        /// 卫生评分
        /// </summary>
        [JsonProperty(PropertyName = "hygiene_rating")]
        public string HygieneRating;
        /// <summary>
        /// 技术评分
        /// </summary>
        [JsonProperty(PropertyName = "technology_rating")]
        public string TechnologyRating;
        /// <summary>
        /// 图片数
        /// </summary>
        [JsonProperty(PropertyName = "image_num")]
        public string ImageNum;
        /// <summary>
        /// 团购数
        /// </summary>
        [JsonProperty(PropertyName = "groupon_num")]
        public string GrouponNum;
        /// <summary>
        /// 优惠数
        /// </summary>
        [JsonProperty(PropertyName = "discount_num")]
        public string DiscountNum;
        /// <summary>
        /// 评论数
        /// </summary>
        [JsonProperty(PropertyName = "comment_num")]
        public string CommentNum;
        /// <summary>
        /// 收藏数
        /// </summary>
        [JsonProperty(PropertyName = "favorite_num")]
        public string FavoriteNum;
        /// <summary>
        /// 签到数
        /// </summary>
        [JsonProperty(PropertyName = "checkin_num")]
        public string CheckinNum;
    }

    public class BaiduPlaceLocation
    {
        /// <summary>
        /// 纬度值
        /// </summary>
        [JsonProperty(PropertyName = "lat")]
        public decimal Lat;
        /// <summary>
        /// 经度值
        /// </summary>
        [JsonProperty(PropertyName = "lng")]
        public decimal Lng;
    }
}
